package controller

import (
	"github.com/wailsapp/wails/v2/pkg/runtime"
)

// Windows 系统API
type Windows struct {
	Base
}

func NewWindows() *Windows {
	return &Windows{}
}

// BrowserOpenURL 默认浏览器打开网址
func (w *Windows) BrowserOpenURL(url string) {
	runtime.BrowserOpenURL(w.ctx, url)
}

// GetOpenDir 获取选择的目录路径
func (w Windows) GetOpenDir() string {
	path, _ := runtime.OpenDirectoryDialog(w.ctx, runtime.OpenDialogOptions{})
	return path
}

// ClipboardGetText 获取剪切板内容
func (w *Windows) ClipboardGetText() (string, error) {
	return runtime.ClipboardGetText(w.ctx)
}

// ClipboardSetText 设置剪切板内容
func (w *Windows) ClipboardSetText(text string) error {
	return runtime.ClipboardSetText(w.ctx, text)
}

// ShellCMD 以shell方式运行cmd命令
func (w *Windows) ShellCMD(cmdStr string, paramStr string) {
	w.shellCMD(cmdStr, paramStr)
}

// OpenConfigDir 打开应用配置目录
func (w *Windows) OpenConfigDir() {
	w.shellCMD("explorer", w.getAppPath())
}
